﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Model;
using BLL;
namespace UI
{
    public partial class 房间Add : Form
    {
        public 房间Add()
        {
            InitializeComponent();
        }
        主界面 f;
        房间和餐台管理 b;
        public 房间Add(主界面 f,房间和餐台管理 b)
        {
            InitializeComponent();
            this.f = f;
            this.b = b;
        }
        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnSure_Click(object sender, EventArgs e)
        {
            string Rname = txtRname.Text;
            string RConsume=txtDiXiaofei.Text;
            string RMount = txtRongNa.Text;
            if (Rname == ""||RConsume==""||RMount=="")
            {
                MessageBox.Show("所有的数据都不能为空!", "温馨提示");
                return;
            }
            房间Model.Rname = Rname;
            房间Model.RConsume = RConsume;
            房间Model.RMount = RMount;
            房间Model.RIsDisCount = checkBox1.Checked.ToString();
            
            List<房间Model> a=new List<房间Model>();
            object fangJian = 房间信息BLL.SelectRTName();
            if (Convert.ToInt32(fangJian)==0)
            {
                int b = 房间信息BLL.Add();
                if (b > 0)
                {
                    MessageBox.Show("添加成功");
                    f.Zz();
                    this.b.show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("添加失败");
                }
            }
            else
            {
                MessageBox.Show("房间已经存在");
            }
        }
    }
}

